<template>
  <a-card  class="info" title="调岗信息表">
      <!-- table区域-begin -->
    <div v-if="dataSource.length != 0">
      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :loading="loading"
        class="j-table-force-nowrap"
        :customRow="customRow"
        @change="handleTableChange">
        <span slot="action" slot-scope="text, record">
          <a @click="handleDetail(record)">详情</a>
        </span>
      </a-table>
    </div>
    <div v-else>暂无调岗信息</div>
    <erp-hr-employee-adjust-post-bill-modal ref="modalForm" @ok="modalFormOk"></erp-hr-employee-adjust-post-bill-modal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import {JeecgListMixin} from '@/mixins/JeecgListMixin'
  import { getAction,postAction } from '@/api/manage'
  import {filterMultiDictText} from '@/components/dict/JDictSelectUtil'
  import {DisabledAuthFilterMixin} from '@/mixins/DisabledAuthFilterMixin'
  import ErpHrEmployeeAdjustPostBillModal from '@/views/erp/hr/adjust/modules/ErpHrEmployeeAdjustPostBillModal'

  export default {
    name: 'ErpHrEmployeeAdjustPostBillList',
    mixins:[JeecgListMixin, mixinDevice, DisabledAuthFilterMixin],
    components: {
      ErpHrEmployeeAdjustPostBillModal
    },
    data () {
      return {
        description: '人员调岗详情',
        //表头
        columns:[],
        //列设置
        settingColumns:[],
        // 列定义
        defColumns: [
          {
            title: '序号',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'单据编号',
            align:"center",
            scopedSlots: {customRender: 'billNo'},
            dataIndex: 'billNo',
          },
          {
            title:'申请人',
            align:"center",
            dataIndex: 'employeeId_dictText',
            scopedSlots: {
            customRender: 'link'
          },
          },
          {
            title:'预计到岗时间',
            align:"center",
            dataIndex: 'arrivalTime',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'是否外派',
            align:"center",
            dataIndex: 'isExpatriate_dictText',
          },
          {
            title:'调整前部门',
            align:"center",
            dataIndex: 'beforeDepartId_dictText',
          },
          {
            title:'调整前岗位',
            align:"center",
            dataIndex: 'beforePostId_dictText',
          },
          {
            title:'调整前所属团队',
            align:"center",
            dataIndex: 'beforeTeamId_dictText',
          },
          {
            title:'调整前薪级',
            align:"center",
            dataIndex: 'beforeSalaryScale_dictText',
          },
          {
            title:'调整前车贴（元）',
            align:"center",
            dataIndex: 'beforeVehicleSubsidies',
          },
          {
            title:'调整后部门',
            align:"center",
            dataIndex: 'afterDepartId_dictText',
          },
          {
            title:'调整后岗位',
            align:"center",
            dataIndex: 'afterPostId_dictText',
          },
          {
            title:'调整后所属团队',
            align:"center",
            dataIndex: 'afterTeamId_dictText',
          },
          {
            title:'调整后薪级',
            align:"center",
            dataIndex: 'afterSalaryScale_dictText',
          },
          {
            title:'调整后车贴（元）',
            align:"center",
            dataIndex: 'afterVehicleSubsidies',
          },
          {
            title:'调整原因',
            align:"center",
            dataIndex: 'adjustReason',
            ellipsis: true,
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: {
            filterDropdown: 'filterDropdown',
            filterIcon: 'filterIcon',
            customRender: 'action' }
          }
        ],
        url: {
          list: "/api/erp/hr/adjust/erpHrEmployeeAdjustPostBill/allList?bpmStatus=3",
          queryEmployeeById: '/api/erp/files/employee/erpEmployeeFile/queryPageById',
        },
        //代码生成后需手动设置流程编码
        flowCode: 'onl_erp_hr_employee_adjust_post_bill',
        formUrl: "/hr/adjust/modules/ErpHrEmployeeAdjustPostBillForm",
        formUrlMobile: "",
        beanName:"ErpHrEmployeeAdjustPostBillServiceImpl",
        dictOptions:{},
        superFieldList:[],
        disableMixinCreated: true
      }
    },
    created() {
      this.getSuperFieldList();
    },
    props: {
      employeeId: String
    },
    watch: {
      employeeId: {
        handler: function(val){
          this.getData(val)
        },
        immediate: true
      },
      // BUG4233 查看多人员工档案信息，信息数据被覆盖
      $route(to, from) {
        this.getData(to.query.id)
      },
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      getData(id){
        this.initColumns()
        getAction(this.url.list, { employeeId: id }).then(res => {
          if (res.success) {
            this.dataSource = res.result.records || res.result
          }
        })
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'string',value:'bpmStatus',text:'流程状态',dictCode:''})
        fieldList.push({type:'Text',value:'bpmBizTitle',text:'流程标题',dictCode:''})
        fieldList.push({type:'string',value:'billNo',text:'单据编号',dictCode:''})
        fieldList.push({type:'string',value:'employeeId',text:'申请人',dictCode:''})
        fieldList.push({type:'date',value:'arrivalTime',text:'预计到岗时间'})
        fieldList.push({type:'string',value:'isExpatriate',text:'是否外派',dictCode:'yes_or_no'})
        fieldList.push({type:'string',value:'beforeDepartId',text:'调整前部门',dictCode:''})
        fieldList.push({type:'string',value:'beforePostId',text:'调整前岗位',dictCode:''})
        fieldList.push({type:'string',value:'beforeTeamId',text:'调整前所属团队',dictCode:''})
        fieldList.push({type:'string',value:'beforeSalaryScale',text:'调整前薪级',dictCode:''})
        fieldList.push({type:'BigDecimal',value:'beforeVehicleSubsidies',text:'调整前车贴（元）',dictCode:''})
        fieldList.push({type:'string',value:'afterDepartId',text:'调整后部门',dictCode:''})
        fieldList.push({type:'string',value:'afterPostId',text:'调整后岗位',dictCode:''})
        fieldList.push({type:'string',value:'afterTeamId',text:'调整后所属团队',dictCode:''})
        fieldList.push({type:'string',value:'afterSalaryScale',text:'调整后薪级',dictCode:''})
        fieldList.push({type:'string',value:'afterVehicleSubsidies',text:'调整后车贴（元）',dictCode:''})
        fieldList.push({type:'Text',value:'adjustReason',text:'调整原因',dictCode:''})
        fieldList.push({type:'string',value:'isWorkHandover',text:'工作交接',dictCode:'yes_or_no'})
        fieldList.push({type:'string',value:'workHandoverPerson',text:'工作交接人',dictCode:''})
        fieldList.push({type:'string',value:'isOfficeSupplies',text:'办公设备交接情况',dictCode:'yes_or_no'})
        fieldList.push({type:'string',value:'officeSuppliesPerson',text:'办公设备交接人',dictCode:''})
        fieldList.push({type:'string',value:'isLoan',text:'有无借款',dictCode:'yes_or_no'})
        fieldList.push({type:'BigDecimal',value:'loanMoney',text:'借款金额',dictCode:''})
        fieldList.push({type:'Text',value:'remark',text:'备注',dictCode:''})
        fieldList.push({type:'Text',value:'attachment',text:'附件',dictCode:''})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>
